import request from '@/utils/request'

// 查询计费规则列表
export function listRule(query) {
  return request({
    url: '/system/rule/list',
    method: 'get',
    params: query
  })
}
// 上传图片
export function uploadImage(data) {
  return request({
    url: '/system/minioImage/upload',
    method: 'post',
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// 查询计费规则详细
export function getRule(prId) {
  return request({
    url: '/system/rule/' + prId,
    method: 'get'
  })
}

// 新增计费规则
export function addRule(data) {
  return request({
    url: '/system/rule',
    method: 'post',
    data: data
  })
}

// 修改计费规则
export function updateRule(data) {
  return request({
    url: '/system/rule',
    method: 'put',
    data: data
  })
}

// 删除计费规则
export function delRule(prId) {
  return request({
    url: '/system/rule/' + prId,
    method: 'delete'
  })
}

function getList() {
  loading.value = true
  listRule(queryParams.value).then(response => {
    ruleList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}
